/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "napi/native_api.h"
#include "NativeBufferTest.h"

napi_property_descriptor desc[] = {
    {"oHNativeBufferAlloc", nullptr, OHNativeBufferAlloc, nullptr, nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferReference", nullptr, OHNativeBufferReference, nullptr, nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferUnreference", nullptr, OHNativeBufferUnreference, nullptr, nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferGetConfig", nullptr, OHNativeBufferGetConfig, nullptr, nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferMap", nullptr, OHNativeBufferMap, nullptr, nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferUnmap", nullptr, OHNativeBufferUnmap, nullptr, nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferGetSeqNum", nullptr, OHNativeBufferGetSeqNum, nullptr, nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferAllocAbnormal", nullptr, OHNativeBufferAllocAbnormal, nullptr, nullptr, nullptr, napi_default,
     nullptr},
    {"oHNativeBufferReferenceAbnormal", nullptr, OHNativeBufferReferenceAbnormal, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferUnreferenceAbnormal", nullptr, OHNativeBufferUnreferenceAbnormal, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferMapAbnormal", nullptr, OHNativeBufferMapAbnormal, nullptr, nullptr, nullptr, napi_default,
     nullptr},
    {"oHNativeBufferUnmapAbnormal", nullptr, OHNativeBufferUnmapAbnormal, nullptr, nullptr, nullptr, napi_default,
     nullptr},
    {"oHNativeBufferGetSeqNumAbnormal", nullptr, OHNativeBufferGetSeqNumAbnormal, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferAllocNullptr", nullptr, OHNativeBufferAllocNullptr, nullptr, nullptr, nullptr, napi_default,
     nullptr},
    {"oHNativeBufferAllocNormal", nullptr, OHNativeBufferAllocNormal, nullptr, nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferMapWaitFence0ms", nullptr, OHNativeBufferMapWaitFence0ms, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferMapWaitFence100ms", nullptr, OHNativeBufferMapWaitFence100ms, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferMapWaitFence5000ms", nullptr, OHNativeBufferMapWaitFence5000ms, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferMapWaitFenceNullptr", nullptr, OHNativeBufferMapWaitFenceNullptr, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferMapWaitFenceAbnormal", nullptr, OHNativeBufferMapWaitFenceAbnormal, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferSetMetadataValueEnumTraversal", nullptr, OHNativeBufferSetMetadataValueEnumTraversal, nullptr,
     nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferAllocAbormal", nullptr, OHNativeBufferAllocAbormal, nullptr, nullptr, nullptr, napi_default,
     nullptr},
    {"oHNativeBufferAllocMuch", nullptr, OHNativeBufferAllocMuch, nullptr, nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferFromNativeWindowBufferNullptr", nullptr, OHNativeBufferFromNativeWindowBufferNullptr, nullptr,
     nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferFromNativeWindowBufferNormal", nullptr, OHNativeBufferFromNativeWindowBufferNormal, nullptr,
     nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferGetConfigNullptr", nullptr, OHNativeBufferGetConfigNullptr, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferGetConfigNormal", nullptr, OHNativeBufferGetConfigNormal, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferGetSeqNumNullptr", nullptr, OHNativeBufferGetSeqNumNullptr, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferGetSeqNumNormal", nullptr, OHNativeBufferGetSeqNumNormal, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBuffeMapNullptr", nullptr, OHNativeBuffeMapNullptr, nullptr, nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferMapNormal", nullptr, OHNativeBufferMapNormal, nullptr, nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBuffeMapPlanesNullptr", nullptr, OHNativeBuffeMapPlanesNullptr, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferMapPlanesAbNormal", nullptr, OHNativeBufferMapPlanesAbNormal, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferMapPlanesNormal", nullptr, OHNativeBufferMapPlanesNormal, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBuffeReferenceNullptr", nullptr, OHNativeBuffeReferenceNullptr, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBuffeUnreferenceNullptr", nullptr, OHNativeBuffeUnreferenceNullptr, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferReferenceNormal", nullptr, OHNativeBufferReferenceNormal, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferReferenceMax", nullptr, OHNativeBufferReferenceMax, nullptr, nullptr, nullptr, napi_default,
     nullptr},
    {"oHNativeBufferUnreferenceNormal", nullptr, OHNativeBufferUnreferenceNormal, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBuffeUnmapNullptr", nullptr, OHNativeBuffeUnmapNullptr, nullptr, nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferUnmapNormal", nullptr, OHNativeBufferUnmapNormal, nullptr, nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferGetColorSpaceFirst", nullptr, OHNativeBufferGetColorSpaceFirst, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferSetColorSpaceNormal", nullptr, OHNativeBufferSetColorSpaceNormal, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferSetColorSpaceNullptr", nullptr, OHNativeBufferSetColorSpaceNullptr, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferSetColorSpaceAbnormal", nullptr, OHNativeBufferSetColorSpaceAbnormal, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferGetColorSpaceNullptr", nullptr, OHNativeBufferGetColorSpaceNullptr, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferGetMetadataValueFirst", nullptr, OHNativeBufferGetMetadataValueFirst, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferSetDynamicMetadataValue", nullptr, OHNativeBufferSetDynamicMetadataValue, nullptr, nullptr,
     nullptr, napi_default, nullptr},
    {"oHNativeBufferSetMetadataValueTimes", nullptr, OHNativeBufferSetMetadataValueTimes, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferSetStaticMetadataValue", nullptr, OHNativeBufferSetStaticMetadataValue, nullptr, nullptr,
     nullptr, napi_default, nullptr},
    {"oHNativeBufferSetMetadataValue", nullptr, OHNativeBufferSetMetadataValue, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferSetNullMetadataValue", nullptr, OHNativeBufferSetNullMetadataValue, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferSetMetadataValueNullptr", nullptr, OHNativeBufferSetMetadataValueNullptr, nullptr, nullptr,
     nullptr, napi_default, nullptr},
    {"oHNativeBufferGetMetadataValueAbnormal", nullptr, OHNativeBufferGetMetadataValueAbnormal, nullptr, nullptr,
     nullptr, napi_default, nullptr},
    {"oHNativeBufferGetMetadataValueNullptr", nullptr, OHNativeBufferGetMetadataValueNullptr, nullptr, nullptr,
     nullptr, napi_default, nullptr},
    {"oHNativeBufferY8Y16USAGEandAlloc", nullptr, OHNativeBufferY8Y16USAGEandAlloc, nullptr, nullptr,
     nullptr, napi_default, nullptr},
    {"oHNativeBufferSetMetadataValueREGION", nullptr, OHNativeBufferSetMetadataValueREGION, nullptr, nullptr,
     nullptr, napi_default, nullptr},
    {"oHNativeBufferIsSupportedNormal", nullptr, OHNativeBufferIsSupportedNormal, nullptr, nullptr,
     nullptr, napi_default, nullptr},
    {"oHNativeBufferIsSupportedNull01", nullptr, OHNativeBufferIsSupportedNull01, nullptr, nullptr,
     nullptr, napi_default, nullptr},
    {"oHNativeBufferIsSupportedNull02", nullptr, OHNativeBufferIsSupportedNull02, nullptr, nullptr,
     nullptr, napi_default, nullptr},
    {"oHNativeBufferIsSupportedAbnormal01", nullptr, OHNativeBufferIsSupportedAbnormal01, nullptr, nullptr,
     nullptr, napi_default, nullptr},
    {"oHNativeBufferIsSupportedAbnormal02", nullptr, OHNativeBufferIsSupportedAbnormal02, nullptr, nullptr,
     nullptr, napi_default, nullptr},
    {"oHNativeBufferIsSupportedMultipleCalls", nullptr, OHNativeBufferIsSupportedMultipleCalls, nullptr, nullptr,
     nullptr, napi_default, nullptr},
    {"oHNativeBufferMapAndGetConfilgNormal", nullptr, OHNativeBufferMapAndGetConfilgNormal, nullptr, nullptr,
     nullptr, napi_default, nullptr},
    {"oHNativeBufferMapAndGetConfilgNull", nullptr, OHNativeBufferMapAndGetConfilgNull, nullptr, nullptr,
     nullptr, napi_default, nullptr},
    {"oHNativeBufferMapAndGetConfilgMultipleCalls01", nullptr, OHNativeBufferMapAndGetConfilgMultipleCalls01, nullptr,
     nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferMapAndGetConfilgMultipleCalls02", nullptr, OHNativeBufferMapAndGetConfilgMultipleCalls02, nullptr,
     nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferMapAll", nullptr, OHNativeBufferMapAll, nullptr, nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferMapAndUnmap", nullptr, OHNativeBufferMapAndUnmap, nullptr, nullptr, nullptr, napi_default, nullptr},
    {"oHNativeBufferWriteToParcelNormal", nullptr, OHNativeBufferWriteToParcelNormal, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferWriteToParcelNull", nullptr, OHNativeBufferWriteToParcelNull, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferReadFromParcelNormal", nullptr, OHNativeBufferReadFromParcelNormal, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferReadFromParcelNull", nullptr, OHNativeBufferReadFromParcelNull, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferReadFromParcelAbnnormal", nullptr, OHNativeBufferReadFromParcelAbnnormal, nullptr, nullptr, nullptr,
     napi_default, nullptr},
    {"oHNativeBufferWriteAndReadParcelMultipleCalls", nullptr, OHNativeBufferWriteAndReadParcelMultipleCalls, nullptr,
     nullptr, nullptr, napi_default, nullptr},
};

EXTERN_C_START
static napi_value Init(napi_env env, napi_value exports)
{
    napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
    return exports;
}
EXTERN_C_END

static napi_module demoModule = {
    .nm_version = 1,
    .nm_flags = 0,
    .nm_filename = nullptr,
    .nm_register_func = Init,
    .nm_modname = "nativebuffer",
    .nm_priv = ((void *)0),
    .reserved = {0},
};

extern "C" __attribute__((constructor)) void RegisterModule(void) { napi_module_register(&demoModule); };
